import React from 'react';
import ReactDOM from 'react-dom';
class App extends React.Component {
  // constructor(){
  //   super()
  //   this.fn2 = ()=>{}
  // }
  state = {
    name: "珠峰"
  }
  fn1() {
    console.log(666)
    console.log(this.state.name)
  }
  fn2 = (...arg) => {
    console.log(arg)
    console.log(this.state.name)
  }
  render() {
    let f = this.fn1.bind(this)
    return <div className=''>

      <button onClick={this.fn1}>按钮1</button>
      <button onClick={this.fn1.bind(this)}>按钮2</button>
      <button onClick={() => { this.fn1() }}>按钮3</button>
      <button onClick={this.fn2}>按钮4</button>


      {/* 传参  bind  要不就箭头函数 ; bind处理传参 事件对象永远在最后一项*/}
      <button onClick={this.fn2.bind(this, 1, 2, 3, 4, 5)}>按钮5</button>
      <button onClick={(e) => {
        this.fn2(1, 2, 3, e, 3, 4, 5, e, 99)
      }}>按钮6</button>

    </div>;
  }
}

ReactDOM.render(<App />, document.getElementById('root'))